ditu=[[2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1],
      [2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 1],
      [2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1],
      [2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
      [2, 2, 2, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
      [3, 3, 3, 3, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1],
      [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
      [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
for hang in range(len(ditu)-1):
    for lie in range(len(ditu[hang])-1):
        if ditu[hang][lie]==1 and ditu[hang][lie+1]==0:
            ditu[hang][lie]=9
        elif ditu[hang][lie]==1 and  ditu[hang][lie-1]==0:
            ditu[hang][lie]=9
        elif ditu[hang][lie]==1 and ditu[hang+1][lie]==0:
            ditu[hang][lie]=9
        elif ditu[hang][lie]==1 and ditu[hang-1][lie]==0:
            ditu[hang][lie]=9
print(ditu)
